package com.jp.fm.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import com.jp.fm.dao.AccountDao;
import com.jp.fm.dao.BillReminderDao;
import com.jp.fm.dao.BudgetDao;
import com.jp.fm.dao.CategoryDao;
import com.jp.fm.dao.TransactionDao;
import com.jp.fm.service.AccountService;
import com.jp.fm.service.BudgetService;
import com.jp.fm.service.CategoryService;
import com.jp.fm.service.PageService;
import com.jp.fm.service.TransactionService;

public class ServletParent extends HttpServlet {

	private static final long serialVersionUID = 1L;

	private TransactionService transactionService = null;
	private CategoryService categoryService = null;
	private BudgetService budgetService = null;
	private PageService pageService = null;
	private AccountService accountService = null;

	private TransactionDao transactionDao = null;
	private AccountDao accountDao = null;
	private CategoryDao categoryDao = null;
	private BudgetDao budgetDao = null;
	private BillReminderDao billReminderDao = null;

	public void init() throws ServletException {

		BillReminderDao brDao = new BillReminderDao();
		AccountDao aDao = new AccountDao();
		CategoryDao cDao = new CategoryDao();
		TransactionDao tDao = new TransactionDao();
		tDao.setCategoryDao(cDao);
		BudgetDao bDao = new BudgetDao();
		bDao.setTransactionDao(tDao);

		AccountService aService = new AccountService();
		aService.setCategoryDao(cDao);
		aService.setTransactionDao(tDao);

		PageService pService = new PageService();
		pService.setAccountDao(aDao);
		pService.setTransactionDao(tDao);
		pService.setAccountService(aService);

		TransactionService tService = new TransactionService();
		tService.setAccountDao(aDao);
		tService.setCategoryDao(cDao);
		tService.setTransactionDao(tDao);

		BudgetService bService = new BudgetService();
		bService.setTransactionDao(tDao);
		bService.setTransactionService(tService);
		bService.setBudgetDao(bDao);

		CategoryService cService = new CategoryService();
		cService.setCategoryDao(cDao);
		cService.setTransactionDao(tDao);
		cService.setTransactionService(tService);

		this.setAccountService(aService);
		this.setBudgetService(bService);
		this.setCategoryService(cService);
		this.setPageService(pService);
		this.setTransactionService(tService);
		this.setAccountDao(aDao);
		this.setBillReminderDao(brDao);
		this.setCategoryDao(cDao);
		this.setBudgetDao(bDao);
		this.setTransactionDao(tDao);
		this.setBillReminderDao(brDao);
	}

	protected final void setBudgetService(final BudgetService budgetService) {
		this.budgetService = budgetService;
	}

	protected final void setTransactionService(
			final TransactionService transactionService) {
		this.transactionService = transactionService;
	}

	protected final void setCategoryService(
			final CategoryService categoryService) {
		this.categoryService = categoryService;
	}

	protected final void setAccountService(final AccountService accountService) {
		this.accountService = accountService;
	}

	protected final void setAccountDao(final AccountDao accountDao) {
		this.accountDao = accountDao;
	}

	protected final void setCategoryDao(final CategoryDao categoryDao) {
		this.categoryDao = categoryDao;
	}

	protected final void setPageService(final PageService pageService) {
		this.pageService = pageService;
	}

	protected final void setBudgetDao(final BudgetDao budgetDao) {
		this.budgetDao = budgetDao;
	}

	protected final TransactionService getTransactionService() {
		return this.transactionService;
	}

	protected final CategoryService getCategoryService() {
		return this.categoryService;
	}

	protected final BudgetService getBudgetService() {
		return this.budgetService;
	}

	protected final PageService getPageService() {
		return this.pageService;
	}

	protected final AccountService getAccountService() {
		return this.accountService;
	}

	protected final AccountDao getAccountDao() {
		return this.accountDao;
	}

	protected final CategoryDao getCategoryDao() {
		return this.categoryDao;
	}

	protected final BudgetDao getBudgetDao() {
		return this.budgetDao;
	}

	protected final TransactionDao getTransactionDao() {
		return this.transactionDao;
	}

	protected final void setTransactionDao(final TransactionDao transactionDao) {
		this.transactionDao = transactionDao;
	}

	protected final BillReminderDao getBillReminderDao() {
		return this.billReminderDao;
	}

	protected final void setBillReminderDao(
			final BillReminderDao billReminderDao) {
		this.billReminderDao = billReminderDao;
	}
}
